home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume23 / sc6.8 / part06 < prev    next >
Encoding:
Internet Message Format  |  1990-10-09  |  28.0 KB

  1. Subject:  v23i026:  The SC Spreadsheet, release 6.8, Part06/06
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 9f24081c 9b059d20 1da94f8e fd069b19
  5.  
  6. Submitted-by: Jeff Buhrt <sawmill!buhrt>
  7. Posting-number: Volume 23, Issue 26
  8. Archive-name: sc6.8/part06
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then feed it
  12. # into a shell via "sh file" or similar.  To overwrite existing files,
  13. # type "sh file -c".
  14. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  15. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  16. # Contents:  Makefile TODO VMS_NOTES crypt.c sc6.8p2.hdr sc6.8p3.hdr
  17. #   sc6.8p4.hdr tutorial.sc
  18. # Wrapped by rsalz@litchi.bbn.com on Fri Jul 13 15:24:23 1990
  19. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  20. echo If this archive is complete, you will see the following message:
  21. echo '          "shar: End of archive 6 (of 6)."'
  22. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  23.   echo shar: Will not clobber existing file \"'Makefile'\"
  24. else
  25.   echo shar: Extracting \"'Makefile'\" \(4558 characters\)
  26.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  27. X# Specify the name of the program.
  28. X# All documentation and installation keys on this value.
  29. X# 
  30. Xname=sc
  31. XNAME=SC
  32. X
  33. X# This is where the install step puts it.
  34. X#EXDIR=/v/rgb/bin/psx
  35. XEXDIR=/usr/local/bin
  36. X
  37. X# This is where the man page goes.
  38. X#MANDIR=/usr/man/man1
  39. XMANDIR=/usr/man/manl
  40. X
  41. X# Set SIMPLE for lex.c if you don't want arrow keys or lex.c blows up
  42. X#SIMPLE=-DSIMPLE
  43. X
  44. X# Set DOBACKUPS if you would like a backup copy of a source file on a save
  45. XDOBACKUPS=-DDOBACKUPS
  46. X
  47. X# Set INTERNATIONAL if you need 8 bit characters.  You should
  48. X# not set this if you are running 5.3.0.  I think it is OK in 5.3.1.
  49. X#INTERNATIONAL=-DINTERNATIONAL
  50. X# Set SIGVOID if signal routines are type void.  System 5.3, VMS and ANSI C
  51. X# Compliant systems use this.  Most BSD systems do not.
  52. X#SIGVOID=-DSIGVOID
  53. X
  54. X# Set IEEE_MATH if you need setsticky() calls in your signal handlers
  55. X#
  56. X#IEEE_MATH=-DIEEE_MATH
  57. X
  58. X# This is the name of a pager like "more" If the line is commented out
  59. X# then "more" will be used. "pg" may be appropriate for SYSV
  60. XPAGER=-DDFLT_PAGER=\"less\"
  61. X
  62. X# Use this for system V.2
  63. X#CFLAGS= -O -DSYSV2 
  64. X#LDFLAGS=
  65. X#LIB=-lm -lPW -lcurses
  66. X
  67. X# Use this for system V.3
  68. X#CFLAGS= -g -DSYSV3
  69. X#LDFLAGS=
  70. X#LIB=-lm -lcurses -lPW
  71. X
  72. X# Microport
  73. X#CFLAGS= -DSYSV2 -O -DUPORT -Ml
  74. X#LDFLAGS=-Ml
  75. X#LIB=-lm -lcurses -lPW
  76. X
  77. X# Use this for BSD 4.2
  78. X#CFLAGS= -O -DBSD42
  79. X#LDFLAGS=
  80. X#LIB=-lm -lcurses -ltermcap
  81. X
  82. X# Use this for Sequent boxes
  83. XCC=atscc
  84. XCFLAGS=-O -DBSD42
  85. XLDFLAGS= -s
  86. XLIB=-lm -lcurses -ltermcap
  87. XPSCLIB=-lseq
  88. X
  89. X# Use this for BSD 4.3
  90. X#CFLAGS= -O -DBSD43
  91. X#LDFLAGS=
  92. X#LIB=-lm -lcurses -ltermcap
  93. X
  94. X# Use this for system III (XENIX)
  95. X#CFLAGS= -O -DSYSIII
  96. X#LDFLAGS= -i
  97. X#LIB=-lm -lcurses -ltermcap
  98. X
  99. X# Use this for VENIX
  100. X#CFLAGS= -DVENIX -DBSD42 -DV7
  101. X#LDFLAGS= -z -i 
  102. X#LIB=-lm -lcurses -ltermcap
  103. X
  104. X# All of the source files
  105. XSRC=sc.h sc.c lex.c gram.y interp.c crypt.c xmalloc.c cmds.c range.c help.c \
  106. X    vi.c eres.sed sres.sed Makefile psc.c vmtbl.c version.c
  107. X
  108. X# The objects
  109. XOBJS=sc.o interp.o cmds.o crypt.o xmalloc.o range.o help.o vi.o lex.o gram.o \
  110. X    vmtbl.o version.o
  111. X
  112. X# The documents in the Archive
  113. XDOCS=README CHANGES sc.doc psc.doc tutorial.sc VMS_NOTES BSD_BUGS
  114. X
  115. X$(name):$(PAR)     $(OBJS)
  116. X    $(CC) ${CFLAGS} ${LDFLAGS} ${OBJS} ${LIB} -o $(name)
  117. X
  118. Xdiff_to_sc:    diff_to_sc.c
  119. X    $(CC) ${CFLAGS} -o dtv diff_to_sc.c
  120. X
  121. Xp$(name):    psc.c pvmtbl.o
  122. X    $(CC) ${CFLAGS} -o p$(name) psc.c pvmtbl.o ${PSCLIB}
  123. X    cp p$(name) $(EXDIR)/p$(name)
  124. X
  125. Xpvmtbl.o: sc.h vmtbl.c
  126. X    $(CC) ${CFLAGS} -c -DPSC vmtbl.c
  127. X    mv vmtbl.o pvmtbl.o
  128. X
  129. Xlex.o:    sc.h y.tab.h gram.o lex.c
  130. X    $(CC) ${CFLAGS} ${SIMPLE} ${IEEE_MATH} ${INTERNATIONAL} ${SIGVOID} -c lex.c
  131. X
  132. Xsc.o:    sc.h sc.c
  133. X    $(CC) ${CFLAGS} ${INTERNATIONAL} ${PAGER} ${SIGVOID} -c sc.c
  134. X
  135. Xinterp.o:    interp.c sc.h
  136. X    $(CC) ${CFLAGS} ${IEEE_MATH} ${SIGVOID} -c interp.c
  137. X
  138. Xgram.o:    sc.h y.tab.h
  139. X
  140. Xcmds.o: cmds.c sc.h
  141. X    $(CC) ${CFLAGS} ${DOBACKUPS} -c cmds.c
  142. X
  143. Xcrypt.o: crypt.c sc.h
  144. X    $(CC) ${CFLAGS} ${DOBACKUPS} -c crypt.c
  145. X
  146. Xrange.o: range.c sc.h
  147. X
  148. Xhelp.o: help.c sc.h
  149. X
  150. Xvi.o: vi.c sc.h
  151. X
  152. Xy.tab.h:    gram.y
  153. X
  154. Xgram.o:    sc.h y.tab.h gram.c
  155. X    $(CC) ${CFLAGS} -c gram.c
  156. X    sed<gram.y >experres.h -f eres.sed;sed < gram.y > statres.h -f sres.sed
  157. X
  158. Xgram.c:    gram.y
  159. X    $(YACC) -d gram.y; mv y.tab.c gram.c
  160. X
  161. Xclean:
  162. X    rm -f *.o *res.h y.tab.h $(name) p$(name) debug core gram.c $(name).1 \
  163. X    $(name).man p$(name).man p$(name).1 y.output
  164. X
  165. Xshar: ${SRC} ${DOCS}
  166. X    shar -c -m 64000 -f shar ${DOCS} ${SRC}
  167. X
  168. Xsshar: ${SRC}
  169. X    shar -c -m 1000000 -f shar ${SRC}
  170. X
  171. Xlint: sc.h sc.c lex.c gram.c interp.c cmds.c crypt.c
  172. X    lint ${CFLAGS} ${SIMPLE} sc.c lex.c gram.c interp.c cmds.c crypt.c \
  173. X    range.c xmalloc.c help.c vi.c -lcurses -lm
  174. X
  175. Xinspect: sc.h sc.c lex.c gram.c interp.c cmds.c crypt.c
  176. X    /bruces/ianj/bin/i386/inspect -abv -t 8 sc.c lex.c gram.c interp.c \
  177. X    cmds.c crypt.c range.c xmalloc.c help.c vi.c
  178. X
  179. Xprint: sc.h gram.y sc.c lex.c interp.c cmds.c crypt.c 
  180. X    prc sc.h gram.y sc.c lex.c interp.c cmds.c crypt.c | lpr
  181. X
  182. X$(name).1:    sc.doc
  183. X    sed -e s/pname/$(name)/g -e s/PNAME/$(NAME)/g sc.doc >  $(name).1
  184. X
  185. X$(name).man:    $(name).1
  186. X    nroff -man $(name).1 > $(name).man
  187. X
  188. Xlaser:    $(name).1
  189. X    itpf -x -Pim2 -man $(name).1
  190. X
  191. Xp$(name).1:    psc.doc
  192. X    sed -e s/pname/$(name)/g -e s/PNAME/$(NAME)/g psc.doc >  p$(name).1
  193. X
  194. Xp$(name).man:    p$(name).1
  195. X    nroff -man p$(name).1 > p$(name).man
  196. X
  197. Xinstall: $(EXDIR)/$(name)
  198. X
  199. Xinst-man: $(MANDIR)/$(name).1
  200. X
  201. X$(EXDIR)/$(name): $(name)
  202. X    -mv $(EXDIR)/$(name) $(EXDIR)/$(name).old
  203. X    cp $(name) $(EXDIR)
  204. X    strip $(EXDIR)/$(name)
  205. X
  206. X$(MANDIR)/$(name).1: $(name).1
  207. X    cp $(name).1 $(MANDIR)
  208. X
  209. Xdiffs: ${SRC}
  210. X    for i in ${SRC} ${DOCS} ;\
  211. X        do \
  212. X        rcsdiff -c -r6.1 $$i ;\
  213. X        done
  214. X
  215. Xtest: test.o vmtbl.o
  216. X    $(CC) ${CFLAGS} ${LDFLAGS} test.o vmtbl.o ${LIB} -o test
  217. END_OF_FILE
  218.   if test 4558 -ne `wc -c <'Makefile'`; then
  219.     echo shar: \"'Makefile'\" unpacked with wrong size!
  220.   fi
  221.   # end of 'Makefile'
  222. fi
  223. if test -f 'TODO' -a "${1}" != "-c" ; then 
  224.   echo shar: Will not clobber existing file \"'TODO'\"
  225. else
  226.   echo shar: Extracting \"'TODO'\" \(3738 characters\)
  227.   sed "s/^X//" >'TODO' <<'END_OF_FILE'
  228. Xdone/tested: (Jeff Buhrt)
  229. X6.7
  230. X1) added a per row memory allocation
  231. X    -runs in about 1/2 run time and 1/3 the space of 6.6vm.1
  232. X    -insert/delete row now just moves pointers (# == maxrow+1-currow)
  233. X        and blanks one row (of columns (maxcol))
  234. X    -as the number of cells grows the size is more linear
  235. X        (no more ##Meg images except for 100,000's of rows....)
  236. X    -row to column pointer translation is done by a macro (ATBL)
  237. X        that returns a pointer to the cell pointer.
  238. X        *ATBL would be a pointer to a *ent (cell).
  239. X    -the maximum # of columns is limited by ABSMAXCOLS or
  240. X        sizeof(struct ent *)*maxcols (whichever is smaller)
  241. X        (702 * 4 = 2808 is no real limit even for 286 large model)
  242. X    -the maximum # of rows is limited by the virtual memory limit or
  243. X        sizeof(struct ent **)*maxrows (whichever is smaller)
  244. X        (4*X=64k, X=16384 rows (excluding malloc overhead) on
  245. X            a '286 large model. Even w/ 3.25Meg and 10Mhz)
  246. X        (plus of course any memory used for cells)
  247. X2) dolookup (int vs double)
  248. X3) dolookup calling eval w/ ent * not enode *
  249. X     (dolookup called w/ ent * not enode *)
  250. X4) cleaned up a lot of .... *x = 0 to  (.... *)0 (cmds, interp)
  251. X5) psc: fwidth/precision were reversed on the output
  252. X6) Backup copy (on save) using same mode to [path/]#file~
  253. X     (will prompt if a backup fails)
  254. X7) put y/n prompt function into yn_ask(mesg)
  255. X8) found a move(x,y) in sc -> move(y,x) and only move when needed
  256. X9) we use FullUpdate || changed (to see if ANY cells changed) 
  257. X    before trying to redraw the screen in update
  258. X    (now we don't try to redraw every time a key is hit)
  259. X    -if we are stand[ing]out we do not create a cell just to force a
  260. X     standout inside the repaint section of update()
  261. X    -only draw blank cells if we cleared it or it is standing out
  262. X    reason: the less work (what to update) curses has to do, the faster
  263. X        a screen update will be (less cpu required)
  264. X14) {insert, delete}col replaced w/ {open,close}col(currow, numcol_to_insert)
  265. X    (limits looping)
  266. X6.7.1.1
  267. X15) goto nonexistant cell may loop
  268. X16) make sure that startup size will at least fill the screen w/ cells.
  269. X17) added version.c
  270. X6.7.1.2
  271. X18) When we would normally die w/o saving (SIGQUIT, etc), we now ask
  272. X    if people would like to save the current spreadsheet.
  273. X    If 'y', saves to the current file name, otherwise ~/SC.SAVE,
  274. X    then /tmp/SC.SAVE if all else fails.
  275. X6.7.1.3
  276. X19) don't use malloc.c for production code
  277. X20) progname is now truncated to just the basename (systems w/ long paths
  278. X    caused problems)
  279. X
  280. Xtodo:
  281. X1) autobackup of things typed in.
  282. X    idea: each cell change output to a stdio open file
  283. X        in the save format, fflush() every so often...
  284. X        (diffs w/r to the original file)
  285. X2) lock/freeze (glue down) a section of the screen (the rest of the screen
  286. X    scrolls but a row/column/block stays fixed on the screen)
  287. X3) (seems ok, but check) FIX the insert/delete row functions.
  288. X    a) column of equations (EX: E50 = E49+D50)
  289. X    b) insert a few rows, look at the equations below the insert point
  290. X    c) delete the inserted rows
  291. X    d) The equations should now be the same as in (a), but they are not...
  292. X4) make sure ISVALID should <not> be used in place of checkbounds
  293. X    in interp.c
  294. X5) hide range
  295. X6) block moving into range
  296. X7) chain cells w/ equations into a linked list or dependency tree
  297. X    -have a top level eval, eval and UPDATE all lower nodes
  298. X8) an option to go into a ^R like <mode>
  299. X    ++data entry fields (highlight entry cells)....
  300. X    ++only allow entry in these cells....
  301. X10) don't redraw the whole screen all the time 
  302. X    (only cells that change, (in addition to what is in 'fixed #9'))
  303. X11) add uemacs keybinding stuff
  304. X12) add uemacs macro language
  305. X13) add uemacs command completion
  306. X14) insertrow should be openrow w/ a count arg (limits looping)
  307. X15) on a Get if the buffer hasn't been written, ask to overwrite
  308. END_OF_FILE
  309.   if test 3738 -ne `wc -c <'TODO'`; then
  310.     echo shar: \"'TODO'\" unpacked with wrong size!
  311.   fi
  312.   # end of 'TODO'
  313. fi
  314. if test -f 'VMS_NOTES' -a "${1}" != "-c" ; then 
  315.   echo shar: Will not clobber existing file \"'VMS_NOTES'\"
  316. else
  317.   echo shar: Extracting \"'VMS_NOTES'\" \(4341 characters\)
  318.   sed "s/^X//" >'VMS_NOTES' <<'END_OF_FILE'
  319. XFrom: ihnp4!gargoyle!oddjob!noao!arizona!naucse!jdc (John Campbell)
  320. XTo: arizona!noao!oddjob!gargoyle!ihnp4!nsc!nscpdc!rgb
  321. XSubject: VMS SC
  322. X
  323. XVMS USERS:
  324. X
  325. XBob Bond has been generous enough to give me free rein in adding what I
  326. Xthink is needed to make SC run on VMS.  Any problems with VMS should be
  327. Xdirected to me--they are not Bob's fault.
  328. X
  329. XThe VMS SC is "SIMPLE" for the most part, except that the arrow keys
  330. X(instead of hjkl) will move you around the cells.  The VMS version of SC
  331. Xwill not interact with the Bourne shell (obviously), which means that CRYPT
  332. Xand EXTERNAL FUNCTIONS will not be available.
  333. X
  334. XIf you have a 'C' compiler and GNU Bison then you should be able to get
  335. XSC running on VMS by following the instructions below.
  336. X
  337. XStep 1:  Get all the files
  338. X
  339. XI've heard of a few sites that can unpack unix shar files directly on
  340. XVMS.  Most people, however, will need access to a unix machine to get
  341. Xthe original distribution unpacked.  At this time you should also build
  342. Xexperres.h and statres.h and perhaps run the man pages off if you need
  343. Xto port the documentation. To build the two "missing" hearder files:
  344. X   sed <gram.y >experres.h -f eres.sed
  345. X   sed <gram.y >statres.h -f sres.sed
  346. X
  347. XStep 2: Cut out BUILD.COM and GETOPT.C
  348. X
  349. XAt the end of this file are two other pieces: BUILD.COM and GETOPT.C.  After
  350. Xyou've moved everything to VMS, cut BUILD.COM and GETOPT.C out of here and
  351. Xput them in the same directory as the rest of the SC distribution.
  352. X
  353. XStep 3: Build it
  354. X
  355. XTheoretically all you now need to do is @BUILD and SC (as well as PSC)
  356. Xwill be running on VMS.  If you have problems feel free to contact me
  357. Xat ...!arizona!naucse!jdc  (or even call at 602-523-6259).
  358. X
  359. X---------------------cut here for BUILD.COM--------------------------
  360. X$! VMS command file to build SC and PSC (requires bison)
  361. X$! SC:
  362. X$ bison -d gram.y
  363. X$ ren gram_tab.c gram.c
  364. X$ cc  /define=("SIMPLE","SIGVOID") sc.c
  365. X$ cc  /define=("SIMPLE","SIGVOID") gram.c
  366. X$ cc  /define=("SIMPLE","SIGVOID") lex.c
  367. X$ cc  /define=("SIMPLE","SIGVOID") interp
  368. X$ cc  /define=("SIMPLE","SIGVOID") cmds
  369. X$ cc  /define=("SIMPLE","SIGVOID") xmalloc
  370. X$ cc  /define=("SIMPLE","SIGVOID") range
  371. X$ cc  /define=("SIMPLE","SIGVOID") help
  372. X$ link sc.obj,lex.obj,gram.obj,interp.obj,cmds.obj,xmalloc.obj,-
  373. X       range.obj,help.obj,sys$library:vaxcrtl.olb/lib
  374. X$ !
  375. X$ ! Create VMS foreign command symbol to test SC
  376. X$ !
  377. X$ sc == "$" + f$logical("SYS$DISK") + f$directory() + "SC.EXE"
  378. X$!
  379. X$! Now PSC
  380. X$!
  381. X$ cc psc.c
  382. X$ cc getopt.c
  383. X$ link psc,getopt,sys$library:vaxcrtl.olb/lib
  384. X$ !
  385. X$ ! Create VMS foreign command symbol to test PSC (Note that
  386. X$ ! PSC reads SYS$INPUT and writes to SYS$OUTPUT, so use
  387. X$ ! DEFINE/USER to redirect.)
  388. X$ !
  389. X$ psc == "$" + f$logical("SYS$DISK") + f$directory() + "PSC.EXE"
  390. X
  391. X---------------------cut here for GETOPT.C------------------------
  392. X/*
  393. X * getopt - get option letter from argv
  394. X *      This software is in the public domain
  395. X *      Originally written by Henry Spencer at the U. of Toronto
  396. X */
  397. X
  398. X#include <stdio.h>
  399. X
  400. Xchar    *optarg;        /* Global argument pointer. */
  401. Xint     optind = 0;     /* Global argv index. */
  402. X
  403. Xstatic char     *scan = NULL;   /* Private scan pointer. */
  404. X
  405. X/* extern char     *index();  obsolete, used strchr (JDC). */
  406. X
  407. Xint
  408. Xgetopt(argc, argv, optstring)
  409. Xint argc;
  410. Xchar *argv[];
  411. Xchar *optstring;
  412. X{
  413. X        register char c;
  414. X        register char *place;
  415. X
  416. X        optarg = NULL;
  417. X
  418. X        if (scan == NULL || *scan == '\0') {
  419. X                if (optind == 0)
  420. X                        optind++;
  421. X
  422. X                if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
  423. X                        return(EOF);
  424. X                if (strcmp(argv[optind], "--")==0) {
  425. X                        optind++;
  426. X                        return(EOF);
  427. X                }
  428. X
  429. X                scan = argv[optind]+1;
  430. X                optind++;
  431. X        }
  432. X
  433. X        c = *scan++;
  434. X        place = strchr(optstring, c);
  435. X
  436. X        if (place == NULL || c == ':') {
  437. X                fprintf(stderr, "%s: unknown option -%c\n", argv[0], c);
  438. X                return('?');
  439. X        }
  440. X
  441. X        place++;
  442. X        if (*place == ':') {
  443. X                if (*scan != '\0') {
  444. X                        optarg = scan;
  445. X                        scan = NULL;
  446. X                } else {
  447. X                        optarg = argv[optind];
  448. X                        optind++;
  449. X                }
  450. X        }
  451. X
  452. X        return(c);
  453. X}
  454. END_OF_FILE
  455.   if test 4341 -ne `wc -c <'VMS_NOTES'`; then
  456.     echo shar: \"'VMS_NOTES'\" unpacked with wrong size!
  457.   fi
  458.   # end of 'VMS_NOTES'
  459. fi
  460. if test -f 'crypt.c' -a "${1}" != "-c" ; then 
  461.   echo shar: Will not clobber existing file \"'crypt.c'\"
  462. else
  463.   echo shar: Extracting \"'crypt.c'\" \(3640 characters\)
  464.   sed "s/^X//" >'crypt.c' <<'END_OF_FILE'
  465. X/*
  466. X * Encryption utilites
  467. X * Bradley Williams    
  468. X * {allegra,ihnp4,uiucdcs,ctvax}!convex!williams
  469. X * $Revision: 6.8 $
  470. X */
  471. X
  472. X#include <stdio.h>
  473. X#include <curses.h>
  474. X
  475. X#if defined(BSD42) || defined(BSD43)
  476. X#include <sys/file.h>
  477. X#else
  478. X#include <fcntl.h>
  479. X#endif
  480. X
  481. X#include "sc.h"
  482. X
  483. Xchar        *strcpy();
  484. X
  485. X#ifdef SYSV3
  486. Xvoid exit();
  487. X#endif
  488. X
  489. Xint         Crypt = 0;
  490. X
  491. Xcreadfile (save, eraseflg)
  492. Xchar *save;
  493. Xint  eraseflg;
  494. X{
  495. X    register FILE *f;
  496. X    int pipefd[2];
  497. X    int fildes;
  498. X    int pid;
  499. X
  500. X    if (eraseflg && strcmp(save, curfile) && modcheck(" first")) return;
  501. X
  502. X    if ((fildes = open(findhome(save), O_RDONLY, 0)) < 0)
  503. X    {
  504. X    error ("Can't read file \"%s\"", save);
  505. X    return;
  506. X    }
  507. X
  508. X    if (eraseflg) erasedb ();
  509. X
  510. X    if (pipe(pipefd) < 0) {
  511. X    error("Can't make pipe to child");
  512. X    return;
  513. X    }
  514. X
  515. X    deraw();
  516. X    if ((pid=fork()) == 0)              /* if child  */
  517. X    {
  518. X    (void) close (0);          /* close stdin */
  519. X    (void) close (1);          /* close stdout */
  520. X    (void) close (pipefd[0]);      /* close pipe input */
  521. X    (void) dup (fildes);          /* standard in from file */
  522. X    (void) dup (pipefd[1]);          /* connect to pipe */
  523. X    (void) fprintf (stderr, " ");
  524. X    (void) execl ("/bin/sh", "sh", "-c", "crypt", (char *)0);
  525. X    exit (-127);
  526. X    }
  527. X    else                  /* else parent */
  528. X    {
  529. X    (void) close (fildes);
  530. X    (void) close (pipefd[1]);      /* close pipe output */
  531. X    if ((f = fdopen (pipefd[0], "r")) == (FILE *)0)
  532. X    {
  533. X        (void) kill (pid, -9);
  534. X        error ("Can't fdopen file \"%s\"", save);
  535. X        (void) close (pipefd[0]);
  536. X        return;
  537. X    }
  538. X    }
  539. X
  540. X    loading++;
  541. X    while (fgets(line,sizeof line,f)) {
  542. X    linelim = 0;
  543. X    if (line[0] != '#') (void) yyparse ();
  544. X    }
  545. X    --loading;
  546. X    (void) fclose (f);
  547. X    (void) close (pipefd[0]);
  548. X    while (pid != wait(&fildes)) /**/;
  549. X    goraw();
  550. X    linelim = -1;
  551. X    modflg++;
  552. X    if (eraseflg) {
  553. X    (void) strcpy (curfile, save);
  554. X    modflg = 0;
  555. X    }
  556. X    EvalAll();
  557. X}
  558. X
  559. Xcwritefile (fname, r0, c0, rn, cn)
  560. Xchar *fname;
  561. Xint r0, c0, rn, cn;
  562. X{
  563. X    register FILE *f;
  564. X    int pipefd[2];
  565. X    int fildes;
  566. X    int pid;
  567. X    char save[PATHLEN];
  568. X    char *fn;
  569. X    char *busave;
  570. X
  571. X    if (*fname == '\0') fname = &curfile[0];
  572. X
  573. X    fn = fname;
  574. X    while (*fn && (*fn == ' '))  /* Skip leading blanks */
  575. X    fn++;
  576. X
  577. X    if ( *fn == '|' ) {
  578. X    error ("Can't have encrypted pipe");
  579. X    return(-1);
  580. X    }
  581. X
  582. X    (void) strcpy(save,fname);
  583. X
  584. X    busave = findhome(save);
  585. X#ifdef DOBACKUPS
  586. X    if (!backup_file(busave) &&
  587. X    (yn_ask("Could not create backup copy, Save anyhow?: (y,n)") != 1))
  588. X        return(0);
  589. X#endif
  590. X    if ((fildes = open (busave, O_TRUNC|O_WRONLY|O_CREAT, 0600)) < 0)
  591. X    {
  592. X    error ("Can't create file \"%s\"", save);
  593. X    return(-1);
  594. X    }
  595. X
  596. X    if (pipe (pipefd) < 0) {
  597. X    error ("Can't make pipe to child\n");
  598. X    return(-1);
  599. X    }
  600. X
  601. X    deraw();
  602. X    if ((pid=fork()) == 0)              /* if child  */
  603. X    {
  604. X    (void) close (0);              /* close stdin */
  605. X    (void) close (1);              /* close stdout */
  606. X    (void) close (pipefd[1]);          /* close pipe output */
  607. X    (void) dup (pipefd[0]);              /* connect to pipe input */
  608. X    (void) dup (fildes);              /* standard out to file */
  609. X    (void) fprintf (stderr, " ");
  610. X    (void) execl ("/bin/sh", "sh", "-c", "crypt", 0);
  611. X    exit (-127);
  612. X    }
  613. X    else                  /* else parent */
  614. X    {
  615. X    (void) close (fildes);
  616. X    (void) close (pipefd[0]);          /* close pipe input */
  617. X    f = fdopen (pipefd[1], "w");
  618. X    if (f == 0)
  619. X    {
  620. X        (void) kill (pid, -9);
  621. X        error ("Can't fdopen file \"%s\"", save);
  622. X        (void) close (pipefd[1]);
  623. X        return(-1);
  624. X    }
  625. X    }
  626. X
  627. X    write_fd(f, r0, c0, rn, cn);
  628. X
  629. X    (void) fclose (f);
  630. X    (void) close (pipefd[1]);
  631. X    while (pid != wait(&fildes)) /**/;
  632. X    (void) strcpy(curfile,save);
  633. X
  634. X    modflg = 0;
  635. X    error ("File \"%s\" written", curfile);
  636. X    goraw();
  637. X    return(0);
  638. X}
  639. X
  640. END_OF_FILE
  641.   if test 3640 -ne `wc -c <'crypt.c'`; then
  642.     echo shar: \"'crypt.c'\" unpacked with wrong size!
  643.   fi
  644.   # end of 'crypt.c'
  645. fi
  646. if test -f 'sc6.8p2.hdr' -a "${1}" != "-c" ; then 
  647.   echo shar: Will not clobber existing file \"'sc6.8p2.hdr'\"
  648. else
  649.   echo shar: Extracting \"'sc6.8p2.hdr'\" \(1033 characters\)
  650.   sed "s/^X//" >'sc6.8p2.hdr' <<'END_OF_FILE'
  651. XFrom @uunet.uu.net:sawmill!buhrt@newton.physics.purdue.edu Thu Jun 21 22:29:01 1990
  652. XReceived: from BBN.COM by pineapple.bbn.com id <AA17053@pineapple.bbn.com>; Thu, 21 Jun 90 22:28:09 -0400
  653. XReceived: from uunet.UU.NET by BBN.COM id aa13834; 21 Jun 90 22:26 EDT
  654. XReceived: from newton.physics.purdue.edu by uunet.uu.net (5.61/1.14) with UUCP 
  655. X    id AA09378; Thu, 21 Jun 90 22:25:54 -0400
  656. XReceived: from pur-ee.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.06) with UUCP 
  657. X    id AA09411; Thu, 21 Jun 90 20:35:48 EDT
  658. XReceived: from newton.physics.purdue.edu by ee.ecn.purdue.edu (5.61/1.22jrs)
  659. X    id AA12085; Thu, 21 Jun 90 16:07:06 -0500
  660. XReceived: from sawmill.UUCP by newton.physics.purdue.edu (5.61/1.34)
  661. X    id AA01673; Thu, 21 Jun 90 16:03:55 -0500
  662. XReceived: by sawmill.UUCP (5.61/1.35)
  663. X    id AA08023; Thu, 21 Jun 90 15:36:20 -0500
  664. XDate: Thu, 21 Jun 90 15:36:20 -0500
  665. XFrom: Jeffery A Buhrt <sawmill!buhrt@newton.physics.purdue.edu>
  666. XMessage-Id: <9006212036.AA08023@sawmill.UUCP>
  667. XTo: uunet!sources@uunet.uu.net
  668. XSubject: Sc6.8 (part 2 of 4)
  669. XStatus: R
  670. X
  671. END_OF_FILE
  672.   if test 1033 -ne `wc -c <'sc6.8p2.hdr'`; then
  673.     echo shar: \"'sc6.8p2.hdr'\" unpacked with wrong size!
  674.   fi
  675.   # end of 'sc6.8p2.hdr'
  676. fi
  677. if test -f 'sc6.8p3.hdr' -a "${1}" != "-c" ; then 
  678.   echo shar: Will not clobber existing file \"'sc6.8p3.hdr'\"
  679. else
  680.   echo shar: Extracting \"'sc6.8p3.hdr'\" \(1033 characters\)
  681.   sed "s/^X//" >'sc6.8p3.hdr' <<'END_OF_FILE'
  682. XFrom @uunet.uu.net:sawmill!buhrt@newton.physics.purdue.edu Thu Jun 21 22:26:46 1990
  683. XReceived: from BBN.COM by pineapple.bbn.com id <AA17038@pineapple.bbn.com>; Thu, 21 Jun 90 22:26:20 -0400
  684. XReceived: from uunet.UU.NET by BBN.COM id aa13680; 21 Jun 90 22:25 EDT
  685. XReceived: from newton.physics.purdue.edu by uunet.uu.net (5.61/1.14) with UUCP 
  686. X    id AA08960; Thu, 21 Jun 90 22:24:37 -0400
  687. XReceived: from pur-ee.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.06) with UUCP 
  688. X    id AA09413; Thu, 21 Jun 90 20:35:53 EDT
  689. XReceived: from newton.physics.purdue.edu by ee.ecn.purdue.edu (5.61/1.22jrs)
  690. X    id AA12199; Thu, 21 Jun 90 16:13:04 -0500
  691. XReceived: from sawmill.UUCP by newton.physics.purdue.edu (5.61/1.34)
  692. X    id AA01686; Thu, 21 Jun 90 16:05:37 -0500
  693. XReceived: by sawmill.UUCP (5.61/1.35)
  694. X    id AA08031; Thu, 21 Jun 90 15:36:37 -0500
  695. XDate: Thu, 21 Jun 90 15:36:37 -0500
  696. XFrom: Jeffery A Buhrt <sawmill!buhrt@newton.physics.purdue.edu>
  697. XMessage-Id: <9006212036.AA08031@sawmill.UUCP>
  698. XTo: uunet!sources@uunet.uu.net
  699. XSubject: Sc6.8 (part 3 of 4)
  700. XStatus: R
  701. X
  702. END_OF_FILE
  703.   if test 1033 -ne `wc -c <'sc6.8p3.hdr'`; then
  704.     echo shar: \"'sc6.8p3.hdr'\" unpacked with wrong size!
  705.   fi
  706.   # end of 'sc6.8p3.hdr'
  707. fi
  708. if test -f 'sc6.8p4.hdr' -a "${1}" != "-c" ; then 
  709.   echo shar: Will not clobber existing file \"'sc6.8p4.hdr'\"
  710. else
  711.   echo shar: Extracting \"'sc6.8p4.hdr'\" \(1033 characters\)
  712.   sed "s/^X//" >'sc6.8p4.hdr' <<'END_OF_FILE'
  713. XFrom @uunet.uu.net:sawmill!buhrt@newton.physics.purdue.edu Thu Jun 21 22:28:08 1990
  714. XReceived: from BBN.COM by pineapple.bbn.com id <AA17045@pineapple.bbn.com>; Thu, 21 Jun 90 22:27:07 -0400
  715. XReceived: from uunet.UU.NET by BBN.COM id aa13803; 21 Jun 90 22:25 EDT
  716. XReceived: from newton.physics.purdue.edu by uunet.uu.net (5.61/1.14) with UUCP 
  717. X    id AA09213; Thu, 21 Jun 90 22:25:23 -0400
  718. XReceived: from pur-ee.UUCP by rutgers.edu (5.59/SMI4.0/RU1.3/3.06) with UUCP 
  719. X    id AA09418; Thu, 21 Jun 90 20:35:51 EDT
  720. XReceived: from newton.physics.purdue.edu by ee.ecn.purdue.edu (5.61/1.22jrs)
  721. X    id AA12577; Thu, 21 Jun 90 16:36:00 -0500
  722. XReceived: from sawmill.UUCP by newton.physics.purdue.edu (5.61/1.34)
  723. X    id AA01715; Thu, 21 Jun 90 16:06:36 -0500
  724. XReceived: by sawmill.UUCP (5.61/1.35)
  725. X    id AA08039; Thu, 21 Jun 90 15:36:57 -0500
  726. XDate: Thu, 21 Jun 90 15:36:57 -0500
  727. XFrom: Jeffery A Buhrt <sawmill!buhrt@newton.physics.purdue.edu>
  728. XMessage-Id: <9006212036.AA08039@sawmill.UUCP>
  729. XTo: uunet!sources@uunet.uu.net
  730. XSubject: Sc6.8 (part 4 of 4)
  731. XStatus: R
  732. X
  733. END_OF_FILE
  734.   if test 1033 -ne `wc -c <'sc6.8p4.hdr'`; then
  735.     echo shar: \"'sc6.8p4.hdr'\" unpacked with wrong size!
  736.   fi
  737.   # end of 'sc6.8p4.hdr'
  738. fi
  739. if test -f 'tutorial.sc' -a "${1}" != "-c" ; then 
  740.   echo shar: Will not clobber existing file \"'tutorial.sc'\"
  741. else
  742.   echo shar: Extracting \"'tutorial.sc'\" \(4292 characters\)
  743.   sed "s/^X//" >'tutorial.sc' <<'END_OF_FILE'
  744. X# This data file was generated by the Spreadsheet Calculator.
  745. X# You almost certainly shouldn't edit it.
  746. X
  747. Xdefine "page4" A70
  748. Xdefine "page3" A49
  749. Xdefine "page2" A29
  750. Xdefine "page1" A9
  751. Xdefine "page5" A89
  752. Xleftstring A1 = "This is a brief sc tutorial."
  753. Xleftstring A3 = "Cells are named by their column and row number.  For example,"
  754. Xleftstring A4 = "Cell A4"
  755. Xleftstring B4 = "Cell B4"
  756. Xleftstring C4 = "Cell C4"
  757. Xleftstring A5 = "Cell A5"
  758. Xleftstring A6 = "Cell A6"
  759. Xleftstring C6 = "Cell C6"
  760. Xleftstring A7 = "Cells range from A0 to AN199."
  761. Xleftstring A8 = "Cells can also be named by the user.  See 'range names' in the manual."
  762. Xleftstring page1 = "You can move the cursor a couple of different ways:"
  763. Xleftstring A11 = "^n, j and the <DOWN> arrow key go down"
  764. Xleftstring A12 = "^p, k and the <UP> arrow key go up"
  765. Xleftstring A13 = "^b, h and the <LEFT> arrow key go left"
  766. Xleftstring A14 = "^f, l and the <RIGHT> arrow key go right"
  767. Xleftstring A15 = "You can go directly to a cell by typing 'g' and the cell name. "
  768. Xleftstring A16 = "'g c6' will take you to cell c6."
  769. Xleftstring A18 = "Cells can contain numbers, formulas, or text."
  770. Xleftstring A19 = "Most of the cells on this page contain text."
  771. Xleftstring C20 = "<Type 'g page2' to continue>"
  772. Xleftstring A22 = "Cell d22 contains text"
  773. Xleftstring D22 = "Text "
  774. Xleftstring A23 = "Cell d23 contains a number"
  775. Xlet D23 = 123.34
  776. Xleftstring A24 = "Cell d24 contains a formula"
  777. Xlet D24 = D23+88
  778. Xleftstring A26 = "To see what the cell contains, just move the cursor"
  779. Xleftstring A27 = "onto the cell.  The contents will show up on line 1 in the brackets."
  780. Xleftstring page2 = "You can enter data into cells like this:"
  781. Xleftstring B30 = "'<text' enters left justified text."
  782. Xleftstring B31 = "'>text' enters right justified text."
  783. Xleftstring B32 = "'=number' enters a number"
  784. Xleftstring B33 = "'=formula' enters a formula."
  785. Xleftstring A35 = "Try duplicating d22 through d24 in e22 though e24."
  786. Xleftstring A37 = "You erase a cell by typing 'x' with the cursor on the cell."
  787. Xleftstring C40 = "<Type 'g page3' to continue>"
  788. Xleftstring A42 = "Here is a typical use for numbers and formulas:"
  789. Xlet A44 = 10.3
  790. Xlet B44 = 1877.5
  791. Xlet C44 = 234.7
  792. Xlet E44 = @sum(A44:C44)
  793. Xlet A45 = 44.56
  794. Xlet B45 = 44.3
  795. Xlet C45 = -3
  796. Xlet E45 = @sum(A45:C45)
  797. Xlet A46 = 88.74
  798. Xlet B46 = 8000
  799. Xlet C46 = -9
  800. Xlet E46 = @sum(A46:C46)
  801. Xlet A47 = 99.2
  802. Xlet B47 = -88
  803. Xlet C47 = -44.6
  804. Xlet E47 = @sum(A47:C47)
  805. Xlet page3 = @sum(A44:A47)
  806. Xlet B49 = @sum(B44:B47)
  807. Xlet C49 = @sum(C44:C47)
  808. Xlet E49 = @sum(A44:C47)
  809. Xleftstring A51 = "The data is entered in a44 through c47."
  810. Xleftstring A52 = "Cells a49, b49 and c49 sum their respective columns."
  811. Xleftstring A53 = "Cells e44, e45, e46, and e47 sum their respective rows."
  812. Xleftstring A54 = "Cell E49 is a grand total."
  813. Xleftstring A55 = "Try changing some of the data cells and watch the sums change."
  814. Xleftstring A57 = "You can also edit cells by putting the cursor on the cell and typing:"
  815. Xleftstring B58 = "'e' to edit the numeric portion."
  816. Xleftstring B59 = "'E' to edit the string portion."
  817. Xleftstring C60 = "<Type 'g page4' to continue>"
  818. Xleftstring A62 = "Since you are reading this, you know that you can load "
  819. Xleftstring A63 = "a data base from a file by typing the file name as an"
  820. Xleftstring A64 = "argument to the program.  You can also load or save a "
  821. Xleftstring A65 = "data base using the file commands:"
  822. Xleftstring B67 = "'G file'"
  823. Xleftstring C67 = "Gets the data from an sc file."
  824. Xleftstring B68 = "'P file'"
  825. Xleftstring C68 = "Puts the data from the spreadsheet into a file."
  826. Xleftstring page4 = "Try 'P foo.sc' to write this to the file foo.sc"
  827. Xleftstring A71 = "The Get command erases the current spreadsheet.  "
  828. Xleftstring A72 = "To merge a spreadsheet with the one currently in"
  829. Xleftstring A73 = "the machine, use:"
  830. Xleftstring B75 = "'M file'"
  831. Xleftstring C75 = "Merge the data from a saved sc file."
  832. Xleftstring A77 = "You can also get human readable versions of the data"
  833. Xleftstring A78 = "by using the Write command:"
  834. Xleftstring C80 = "<Type 'g page5' to continue>"
  835. Xleftstring A82 = "Try 'W tut.txt' for a clear text version of the tutorial."
  836. Xleftstring A85 = "This is the end of the tutorial.  We have explored"
  837. Xleftstring A86 = "The basic commands.  Much more detail is available"
  838. Xleftstring A87 = "in the man page."
  839. Xleftstring D91 = "GOOD LUCK!"
  840. END_OF_FILE
  841.   if test 4292 -ne `wc -c <'tutorial.sc'`; then
  842.     echo shar: \"'tutorial.sc'\" unpacked with wrong size!
  843.   fi
  844.   # end of 'tutorial.sc'
  845. fi
  846. echo shar: End of archive 6 \(of 6\).
  847. cp /dev/null ark6isdone
  848. MISSING=""
  849. for I in 1 2 3 4 5 6 ; do
  850.     if test ! -f ark${I}isdone ; then
  851.     MISSING="${MISSING} ${I}"
  852.     fi
  853. done
  854. if test "${MISSING}" = "" ; then
  855.     echo You have unpacked all 6 archives.
  856.     rm -f ark[1-9]isdone
  857. else
  858.     echo You still must unpack the following archives:
  859.     echo "        " ${MISSING}
  860. fi
  861. exit 0
  862. exit 0 # Just in case...
  863.